package eleven.senven.hpb.ui;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import com.alibaba.fastjson.JSONObject;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

import eleven.senven.hpb.R;
import eleven.senven.hpb.bean.OslankaBean02;
import eleven.senven.hpb.config.UrlsHolder;

public class OslankaDtailActivity extends AppCompatActivity {
    private int id;

    ImageView imageview;
    private BitmapUtils bitmapUtils;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_oslanka_dtail);
        id = getIntent().getIntExtra("id", 0);
        imageview= (ImageView) findViewById(R.id.imageview);
        bitmapUtils = new BitmapUtils(getApplicationContext());
        loaddata();
    }

    private void loaddata() {
        HttpUtils httpUtils = new HttpUtils(10000);
        httpUtils.send(HttpRequest.HttpMethod.GET, UrlsHolder.getInstance().getfirstDetailUrl(id), new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                OslankaBean02 oslankaBean02 = JSONObject.parseObject(responseInfo.result, OslankaBean02.class);
                bitmapUtils.display(imageview,oslankaBean02.getResult().getPicture_url());

            }

            @Override
            public void onFailure(HttpException e, String s) {

            }
        });
    }
}
